
#pragma once

namespace Apo
{
	enum SERIALIZERCAPABILITY
	{
		CAN_EXPORT = 1,
		CAN_IMPORT = 2
	};

	enum SCENEFILERESULT
	{
		SCF_OK = 1,
		SCF_CANCEL = 0,
		SCF_ERRUNKNOWN = -1,
		SCF_ERRFILE = -2,
		SCF_ERRPARSE = -3,
		SCF_ERROGRE = -4
	};
	class CBaseSerializer;
	class  CBaseSerializerListen
	{
	public:
		CBaseSerializerListen();
		virtual	~CBaseSerializerListen();
		virtual int  Export() = 0;
		virtual int  Import() =0;
	};

	typedef AlignedObjectArray<CBaseSerializerListen * > CBaseSerializerListenList;
	static   CBaseSerializerListenList m_CBaseSerializerListenList;

	class SocketClientLibExport CBaseSerializer
	{
	public:
		CBaseSerializer(Apo::String typestring = "Base Serializer", unsigned int capability = 0) : m_TypeName(typestring), m_TypeID(0), m_Capability(capability) {};
		virtual ~CBaseSerializer() {};

		// Returns the Serializer Type As String
		inline Apo::String GetTypeString() {return m_TypeName;};
		// Returns the Serializer ID
		inline unsigned int GetTypeID() {return m_TypeID;};
		// Sets the Serializer ID
		inline void         SetTypeID(unsigned int ID) {m_TypeID = ID;};
		// Returns TRUE if this serializer can be used to Export Data
		inline bool         CanExport() {return ((m_Capability & CAN_EXPORT) != 0);};
		// Returns TRUE if this serializer can be used to Import Data
		inline bool         CanImport() {return ((m_Capability & CAN_IMPORT) != 0);};

		/// Does the serializer need a TerminateScene before Import?
		virtual bool RequiresTerminateScene() {return false;};
		/// The function to Export Data, overridden by descendants
		virtual int  Export(bool SaveAs = false) 
		{
// 			for (CBaseSerializerListenList::iterator i =m_CBaseSerializerListenList.begin(); i != m_CBaseSerializerListenList.end();++i)
// 			{
// 				(*i)->Export();
// 			}
			return true;
		};
		/// The function to Import Data, overridden by descendants
		virtual int  Import(Apo::String importfile = "") 
		{
// 			for (CBaseSerializerListenList::iterator i =m_CBaseSerializerListenList.begin(); i != m_CBaseSerializerListenList.end();++i)
// 			{
// 				(*i)->Import();
// 			}
			return true;
		};

		static void addCBaseSerializerListen(CBaseSerializerListen * lis) {m_CBaseSerializerListenList.push_back(lis);} ;
		static void deleteCBaseSerializerListen(CBaseSerializerListen * lis) 
		{
// 			for (CBaseSerializerListenList::iterator i =m_CBaseSerializerListenList.begin(); i != m_CBaseSerializerListenList.end();++i)
// 			{
// 				if ((*i) == lis)
// 					delete (*i);
// 				m_CBaseSerializerListenList.erase(i);
// 				return;
// 			}
		} 

		virtual void updata(float time) {};
		virtual void ReanderUpdata(float time){}
	protected:
		Apo::String m_TypeName;
		unsigned int m_TypeID;
		unsigned int m_Capability;

	};




};
